Skip to content

watch: fix --env-file-if-exists crashing on linux if the file is missing#61870

Merged
nodejs-github-bot merged 9 commits intonodejs:mainfrom
efekrskl:fix/watch-mode-optional-env-crash
Apr 10, 2026
Merged

watch: fix --env-file-if-exists crashing on linux if the file is missing#61870
nodejs-github-bot merged 9 commits intonodejs:mainfrom
efekrskl:fix/watch-mode-optional-env-crash

Conversation

@efekrskl
Copy link
Copy Markdown
Contributor

Fixes #57040

--env-file-if-exists combined with --watch seems to crash in if the .env file is missing (in Linux), this PR aims to fix that.

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Feb 17, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.66%. Comparing base (4f13746) to head (7feebe6).
⚠️ Report is 382 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/fs/recursive_watch.js 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61870      +/-   ##
==========================================
- Coverage   89.72%   89.66%   -0.06%     
==========================================
  Files         675      676       +1     
  Lines      204806   206347    +1541     
  Branches    39355    39534     +179     
==========================================
+ Hits       183761   185021    +1260     
- Misses      13330    13458     +128     
- Partials     7715     7868     +153     
Files with missing lines Coverage Δ
lib/fs.js 98.19% <100.00%> (+<0.01%) ⬆️
lib/internal/fs/watchers.js 88.03% <100.00%> (+0.73%) ⬆️
lib/internal/watch_mode/files_watcher.js 90.69% <100.00%> (+0.08%) ⬆️
lib/internal/fs/recursive_watch.js 85.27% <88.88%> (+0.36%) ⬆️

... and 181 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Renegade334 Renegade334 added the watch-mode Issues and PRs related to watch mode label Feb 18, 2026
@efekrskl efekrskl requested a review from aduh95 February 18, 2026 19:06
@efekrskl
Copy link
Copy Markdown
Contributor Author

@anonrig I've addressed all comments. I've also documented the change in fs.watch options and added some tests, I'm guessing this would be required as it is public facing.

Also, thanks a lot for the quick and detailed feedback!

@efekrskl efekrskl requested a review from anonrig February 19, 2026 22:33
@efekrskl efekrskl requested a review from aduh95 March 4, 2026 18:17
@anonrig anonrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Mar 10, 2026
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 10, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@aduh95 aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 9, 2026
@aduh95 aduh95 removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 9, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 10, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Apr 10, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/61870
✔  Done loading data for nodejs/node/pull/61870
----------------------------------- PR info ------------------------------------
Title      watch: fix --env-file-if-exists crashing on linux if the file is missing (#61870)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     efekrskl:fix/watch-mode-optional-env-crash -> nodejs:main
Labels     author ready, needs-ci, watch-mode
Commits    9
 - watch: fix --env-file-if-exists crashing on linux if the file is missing
 - watch: try/catch instead of existsSync
 - watch: js-lint-fix
 - feat: dont throw on ENOENT if allowMissing is set
 - fix: add default val to throwIfNoEntry
 - feat: make options  an object
 - doc, test: add throwIfNoEntry docs and test
 - fix: check falsy instead of explicit check
 - test: apply review changes
Committers 1
 - Efe Karasakal <dogukankrskl@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Tue, 17 Feb 2026 21:30:31 GMT
   ✔  Approvals: 3
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/61870#pullrequestreview-3917705316
   ✔  - Yagiz Nizipli (@anonrig) (TSC): https://github.com/nodejs/node/pull/61870#pullrequestreview-3919203863
   ✔  - Moshe Atlow (@MoLow): https://github.com/nodejs/node/pull/61870#pullrequestreview-4089850384
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2026-04-10T20:04:24Z: https://ci.nodejs.org/job/node-test-pull-request/72612/
- Querying data for job/node-test-pull-request/72612/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
- Downloading patch for 61870
From https://github.com/nodejs/node
 * branch                  refs/pull/61870/merge -> FETCH_HEAD
✔  Fetched commits as 4dc18ef29d2a..7feebe6256fa
--------------------------------------------------------------------------------
[main d9f9b8b4e8] watch: fix --env-file-if-exists crashing on linux if the file is missing
 Author: Efe Karasakal <dogukankrskl@gmail.com>
 Date: Tue Feb 17 20:19:51 2026 +0100
 2 files changed, 32 insertions(+), 4 deletions(-)
[main a13f6aeb8c] watch: try/catch instead of existsSync
 Author: Efe Karasakal <dogukankrskl@gmail.com>
 Date: Wed Feb 18 17:03:30 2026 +0100
 1 file changed, 22 insertions(+), 17 deletions(-)
[main dec9c6ced5] watch: js-lint-fix
 Author: Efe Karasakal <dogukankrskl@gmail.com>
 Date: Wed Feb 18 18:44:20 2026 +0100
 1 file changed, 12 insertions(+), 12 deletions(-)
Auto-merging lib/fs.js
[main 0221cf2a03] feat: dont throw on ENOENT if allowMissing is set
 Author: Efe Karasakal <dogukankrskl@gmail.com>
 Date: Thu Feb 19 20:34:56 2026 +0100
 5 files changed, 24 insertions(+), 21 deletions(-)
[main d709e640f9] fix: add default val to throwIfNoEntry
 Author: Efe Karasakal <dogukankrskl@gmail.com>
 Date: Thu Feb 19 22:28:53 2026 +0100
 1 file changed, 4 insertions(+), 2 deletions(-)
[main 1246dacc35] feat: make options  an object
 Author: Efe Karasakal <dogukankrskl@gmail.com>
 Date: Thu Feb 19 22:52:02 2026 +0100
 3 files changed, 12 insertions(+), 8 deletions(-)
Auto-merging doc/api/fs.md
[main 8b6be4b1d8] doc, test: add throwIfNoEntry docs and test
 Author: Efe Karasakal <dogukankrskl@gmail.com>
 Date: Thu Feb 19 23:26:10 2026 +0100
 2 files changed, 28 insertions(+)
[main 92e05e2a8d] fix: check falsy instead of explicit check
 Author: Efe Karasakal <dogukankrskl@gmail.com>
 Date: Wed Mar 4 17:58:57 2026 +0100
 1 file changed, 1 insertion(+), 1 deletion(-)
[main 35f914bf86] test: apply review changes
 Author: Efe Karasakal <dogukankrskl@gmail.com>
 Date: Wed Mar 4 19:16:36 2026 +0100
 1 file changed, 5 insertions(+), 5 deletions(-)
   ✔  Patches applied
There are 9 commits in the PR. Attempting autorebase.
(node:355) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/18)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
watch: fix --env-file-if-exists crashing on linux if the file is missing

PR-URL: #61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>

[detached HEAD c2a1d9f771] watch: fix --env-file-if-exists crashing on linux if the file is missing
Author: Efe Karasakal <dogukankrskl@gmail.com>
Date: Tue Feb 17 20:19:51 2026 +0100
2 files changed, 32 insertions(+), 4 deletions(-)
Rebasing (3/18)
Rebasing (4/18)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
watch: try/catch instead of existsSync

PR-URL: #61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>

[detached HEAD 1a0459c3c5] watch: try/catch instead of existsSync
Author: Efe Karasakal <dogukankrskl@gmail.com>
Date: Wed Feb 18 17:03:30 2026 +0100
1 file changed, 22 insertions(+), 17 deletions(-)
Rebasing (5/18)
Rebasing (6/18)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
watch: js-lint-fix

PR-URL: #61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>

[detached HEAD b37b8bf517] watch: js-lint-fix
Author: Efe Karasakal <dogukankrskl@gmail.com>
Date: Wed Feb 18 18:44:20 2026 +0100
1 file changed, 12 insertions(+), 12 deletions(-)
Rebasing (7/18)
Rebasing (8/18)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
feat: dont throw on ENOENT if allowMissing is set

PR-URL: #61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>

[detached HEAD 46761fd848] feat: dont throw on ENOENT if allowMissing is set
Author: Efe Karasakal <dogukankrskl@gmail.com>
Date: Thu Feb 19 20:34:56 2026 +0100
5 files changed, 24 insertions(+), 21 deletions(-)
Rebasing (9/18)
Rebasing (10/18)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
fix: add default val to throwIfNoEntry

PR-URL: #61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>

[detached HEAD 70e730c590] fix: add default val to throwIfNoEntry
Author: Efe Karasakal <dogukankrskl@gmail.com>
Date: Thu Feb 19 22:28:53 2026 +0100
1 file changed, 4 insertions(+), 2 deletions(-)
Rebasing (11/18)
Rebasing (12/18)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
feat: make options an object

PR-URL: #61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>

[detached HEAD 124865454b] feat: make options an object
Author: Efe Karasakal <dogukankrskl@gmail.com>
Date: Thu Feb 19 22:52:02 2026 +0100
3 files changed, 12 insertions(+), 8 deletions(-)
Rebasing (13/18)
Rebasing (14/18)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
doc, test: add throwIfNoEntry docs and test

PR-URL: #61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>

[detached HEAD 55c09c7493] doc, test: add throwIfNoEntry docs and test
Author: Efe Karasakal <dogukankrskl@gmail.com>
Date: Thu Feb 19 23:26:10 2026 +0100
2 files changed, 28 insertions(+)
Rebasing (15/18)
Rebasing (16/18)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
fix: check falsy instead of explicit check

PR-URL: #61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>

[detached HEAD 2b2280191c] fix: check falsy instead of explicit check
Author: Efe Karasakal <dogukankrskl@gmail.com>
Date: Wed Mar 4 17:58:57 2026 +0100
1 file changed, 1 insertion(+), 1 deletion(-)
Rebasing (17/18)
Rebasing (18/18)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
test: apply review changes

PR-URL: #61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>

[detached HEAD cd45c3b022] test: apply review changes
Author: Efe Karasakal <dogukankrskl@gmail.com>
Date: Wed Mar 4 19:16:36 2026 +0100
1 file changed, 5 insertions(+), 5 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/24264942111

@aduh95 aduh95 added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Apr 10, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 10, 2026
@nodejs-github-bot nodejs-github-bot merged commit 726b220 into nodejs:main Apr 10, 2026
87 of 88 checks passed
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Landed in 726b220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. watch-mode Issues and PRs related to watch mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--env-file-if-exists throws error when the .env file doesn't exist and when combined with --watch (now in lts)

6 participants